package com.leased.handler;

import com.leased.exception.DatabaseException;
import com.leased.exception.YCException;
import com.leased.pojo.OperateRecordInfo;
import com.leased.request.operate.OperateRecordRequest;
import com.leased.service.OperateRecordService;
import com.leased.utils.Page;
import com.leased.utils.YCSystemStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by shencx on 2017/8/10.
 */
@Service
public class OperateRecordHandler {

    Logger LOG = LoggerFactory.getLogger(OperateRecordHandler.class);

    @Resource
    private OperateRecordService operateRecordService;

    /**
     * 获取操作记录列表
     * @param operateRecordRequest
     * @return
     * @throws YCException
     */
    public Page<OperateRecordInfo> getOperateRecordPage(OperateRecordRequest operateRecordRequest) throws YCException {
        Page<OperateRecordInfo> page = null;
        try {
            page = operateRecordService.fetchOperateRecordInfoList(operateRecordRequest);
            return page;
        } catch (DatabaseException e) {
            LOG.error("getOperateRecordPage exception",operateRecordRequest);
            throw new YCException(YCSystemStatusEnum.INVOKE_API_RETURN_EXCEPTION.getCode(), YCSystemStatusEnum.INVOKE_API_RETURN_EXCEPTION.getDesc());
        }
    }
}
